/*!
	\file	vec3.h
	\brief	implementations for 3d vector
*/


#ifndef VEC3_H
#define VEC3_H


//! 3D vector
class Vec3
{
public:
	float	x;
	float	y;
	float	z;

public:
	inline				Vec3();
	inline				Vec3( float x, float y, float z );
	inline				Vec3( const Vec3 &v );
	inline				Vec3( const float *v );

	inline const Vec3&	operator=( const Vec3 &v );
	inline				operator float*();
	inline				operator const float*() const;
	inline Vec3			operator-() const;
	inline Vec3			operator+( const Vec3 &v ) const;
	inline Vec3			operator-( const Vec3 &v ) const;
	inline Vec3			operator*( float a ) const;
	inline Vec3			operator/( float a ) const;
	inline void			operator+=( const Vec3 &v );
	inline void			operator-=( const Vec3 &v );
	inline void			operator*=( float a );
	inline void			operator/=( float a );
	inline float		operator*( const Vec3 &v ) const;
	inline bool			operator==( const Vec3 &v ) const;
	inline bool			operator!=( const Vec3 &v ) const;

	float				Length() const;
	inline float		LengthSqr() const;
	void				Normalize();

	void				SetCross( const Vec3 &v1, const Vec3 &v2 );
	void				SetReflectedVector( const Vec3 &normal, const Vec3 &vector );
	void				SetLerp( const Vec3 &v1, const Vec3 &v2, float t );
	void				SetSLerp( const Vec3 &v1, const Vec3 &v2, float t );
	inline void			SetZero();

	void				RotateAroundX( float angle );
	void				RotateAroundY( float angle );
	void				RotateAroundZ( float angle );

	inline bool			IsZero() const;
	inline bool			IsEqual( const Vec3 &v, float eps ) const;

private:
	float				w;
};


#include "vec3.inl"


#endif	// VEC3_H
